package goover.unit02;

public class StringTest01 {
    public static void main(String[] args){
        String str = "ascbfjsjxndfkcaaaxxxncndjs";
        int i = str.lastIndexOf("a");
        System.out.println("索引下标是：" + i);
        char cha = str.charAt(i);
        System.out.println("返回的字符是：" + cha);
        boolean b = str.endsWith("ds");
        System.out.println(b ? "是" : "不是");
        i = str.length();
        System.out.println("字符串的长度为：" + i);
        b = str.equals("ascbfjsjxndfkcaaaxxxncndjs");
        System.out.println(b ? "相同" : "不不相同");
        b = str.isEmpty();
        System.out.println(b ? "字符串长度为0" : "字符串长度不为0");
        b = str.startsWith("asc");
        System.out.println(b ? "是" : "不是");
        b = str.contains("xxx");
        System.out.println(b ? "包含" : "不包含");
        str = str.toUpperCase();
        System.out.println("将字符串转换成大写：" + str);
        str = str.toLowerCase();
        System.out.println("将字符串改成小写：" + str);
        str = String.valueOf(1);
        System.out.println("字符串的表示形式为：" + str);
        char[] c = "abcdefg".toCharArray();
        for(int j = 0; j < c.length;j++){
            if(j == c.length - 1){
                System.out.println(c[j]);
            }else{
                System.out.print(c[j] + ",");
            }
        }
        str = "fakdshsrhawouhssshhh";
        str = str.replace("s","Q");
        System.out.println("替换之后的字符串为：" + str);
        str = "www-baidu-com";
        String[] s = str.split("-");
        for(int x = 0; x < s.length; x++){
            if(x == s.length - 1){
                System.out.println(s[x]);
            }else{
                System.out.print(s[x] + ".");
            }
        }
        str = str.substring(10);
        System.out.println("新字符串为：" + str);
        str = str.substring(0,2);
        System.out.println("新字符串为：" + str);
        str = "   http://www.baidu.com   ";
        str = str.trim();
        System.out.println("去除首尾的空格后：" + str);
    }
}
